home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / dev / gui / gtlayout.lha / Source / LT_GetCode.c < prev    next >
C/C++ Source or Header  |  1999-01-02  |  2KB  |  85 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1999 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <clib/keymap_protos.h>
  17. #include <pragmas/keymap_pragmas.h>
  18.  
  19. /*****************************************************************************/
  20.  
  21. #include "Assert.h"
  22.  
  23. /*****************************************************************************/
  24.  
  25. /****** gtlayout.library/LT_GetCode ******************************************
  26. *
  27. *   NAME
  28. *    LT_GetCode -- Easy raw key event to ANSI conversion.
  29. *
  30. *   SYNOPSIS
  31. *    Key = LT_GetCode(Qualifier,Class,Code,Gadget);
  32. *     D0                  D0     D1    D2    A0
  33. *
  34. *    LONG LT_GetCode(ULONG,ULONG,UWORD,struct Gadget *);
  35. *
  36. *   FUNCTION
  37. *    The user interface layout engine can convert IDCMP_RAWKEY
  38. *    events into ANSI codes. Pass in the data you copied from
  39. *    the IntuiMessage here.
  40. *
  41. *   INPUTS
  42. *    Qualifier - Copied from IntuiMessage->Qualifier
  43. *
  44. *    Class - Copied from IntuiMessage->Class
  45. *
  46. *    Code - Copied from IntuiMessage->Code
  47. *
  48. *    Gadget - Copied from IntuiMessage->IAddress
  49. *
  50. *   RESULT
  51. *    Key - ANSI code generated from the input data
  52. *        or -1 if no such code was to be generated.
  53. *
  54. ******************************************************************************
  55. *
  56. */
  57.  
  58. LONG LIBENT
  59. LT_GetCode(REG(d0) ULONG MsgQualifier,REG(d1) ULONG MsgClass,REG(d2) UWORD MsgCode,REG(a0) struct Gadget *MsgGadget)
  60. {
  61.     if(MsgClass == IDCMP_RAWKEY && !(MsgCode & IECODE_UP_PREFIX) && KeymapBase)
  62.     {
  63.         UBYTE                Buffer[10];
  64.         struct InputEvent    Event;
  65.         LONG                Len;
  66.  
  67.         Event.ie_NextEvent            = NULL;
  68.         Event.ie_Code                 = MsgCode & ~IECODE_UP_PREFIX;
  69.         Event.ie_Qualifier            = MsgQualifier;
  70.         Event.ie_Class                = IECLASS_RAWKEY;
  71.         Event.ie_SubClass            = 0;
  72.         Event.ie_position.ie_addr    = (APTR)MsgGadget;
  73.  
  74.         Buffer[0] = 0;
  75.  
  76.         if((Len = MapRawKey(&Event,Buffer,9,NULL)) > 0)
  77.         {
  78.             if(Buffer[0] != 0x9B || Len == 1)
  79.                 return((LONG)Buffer[0]);
  80.         }
  81.     }
  82.  
  83.     return(-1);
  84. }
  85.